#include "MapBox.h"
#include "EntityCategory.h"

MapBox::MapBox()
{
	
}
void MapBox::init(WindowManager* window, b2World* world, float w, float h, float xLoc, float yLoc, float groundHeight)
{

	width = w;
	height = h;
	x = xLoc;
	y = yLoc;

	b2BodyDef bodyDefBlock;
	bodyDefBlock.position = b2Vec2(x/window->getScale(), (groundHeight-y)/window->getScale());
    bodyDefBlock.type = b2_staticBody;
    body = world->CreateBody(&bodyDefBlock);

	b2PolygonShape ShapeBlock;
	ShapeBlock.SetAsBox((width/2)/window->getScale(), (height/2)/window->getScale()); // Creates a box shape. Divide your desired width and height by 2.
    b2FixtureDef fixtureDef;
    fixtureDef.density = 0.f;  // Sets the density of the body
    fixtureDef.shape = &ShapeBlock; // Sets the shape
	fixtureDef.filter.categoryBits = GROUND;
	//fixtureDef.filter.maskBits = BALL | NPCBODY | CHARACTER;
    body->CreateFixture(&fixtureDef); // Apply the fixture definition
}


MapBox::~MapBox(void)
{
}

void MapBox::drawBox(WindowManager* window, float groundHeight, sf::Color groundColour)
{
	sf::RectangleShape groundSprite(sf::Vector2f(width, height));
	groundSprite.setPosition(sf::Vector2f(x - (width/2), groundHeight-y-(height/2)));
	groundSprite.setFillColor(groundColour);
	groundSprite.setOutlineThickness(1);
	groundSprite.setOutlineColor(sf::Color::Black);
	window->draw(groundSprite);
}
